package com.xie.smfs.item;

import com.xie.smfs.damage.ModDamageSources;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterials;

public class RustyFruitKnifeItem extends SwordItem {
    public RustyFruitKnifeItem(Settings settings) {
        super(ToolMaterials.IRON, 3, -2.4F, settings);
    }

    @Override
    public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
        float damage = (float) this.getAttackDamage();

        // 对目标造成灵异伤害
        target.damage(ModDamageSources.ghost(attacker.getWorld()), damage);

        // 对攻击者造成同等伤害（保留自伤逻辑）
        attacker.damage(ModDamageSources.ghost(attacker.getWorld()), damage);

        // 消耗耐久度
        stack.damage(1, attacker, (e) -> e.sendToolBreakStatus(attacker.getActiveHand()));

        // 返回 true 表示攻击成功处理，不要调用 super.postHit()
        return true;
    }
}